﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TransCend.Util
{
    [Serializable]
    public sealed class ExceptionUtil
    {

        public ExceptionUtil() { }

        public static Exception BuildException(string typeName, string methodName, string message)
        {
            return new Exception(string.Format("The exception:{0} has been thrown by method:{1} in type:{2}.", message, methodName, typeName));
        }

        public static Exception BuildException(Type type, string methodName, string message)
        {
            return BuildException(type.FullName, methodName, message);
        }

        public static ArgumentNullException BuildArgumentNullException(string typeName, string methodName, string argument)
        {
            return new ArgumentNullException(argument, string.Format("The argument:{0} of method:{1} in type:{2} is null.", argument, methodName, typeName));
        }

        public static ArgumentNullException BuildArgumentNullException(Type type, string methodName, string argument)
        {
            return BuildArgumentNullException(type.FullName, methodName, argument);
        }

       
        public static Exception ThrowException(string typeName, string methodName, string message)
        {
            throw BuildException(typeName, methodName, message);
        }

        public static void ThrowArgumentNullException(string typeName, string methodName, string argument)
        {
            throw BuildArgumentNullException(typeName, methodName, argument);
        }

        
    }
}
